﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Erp.Migrations
{
    /// <inheritdoc />
    public partial class modify_table_OutboundRec_1 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "OutboundRecs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    InvChgTypeCode = table.Column<string>(type: "text", nullable: false),
                    InvChgTypeName = table.Column<string>(type: "text", nullable: false),
                    MatlWhseId = table.Column<Guid>(type: "uuid", nullable: false),
                    OrdNo = table.Column<string>(type: "text", nullable: false),
                    OutboundStas = table.Column<int>(type: "integer", nullable: false),
                    OutboundAmt = table.Column<decimal>(type: "numeric(18,4)", nullable: true),
                    OutboundTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    Invono = table.Column<string>(type: "text", nullable: true),
                    InvoicingTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    Exp = table.Column<string>(type: "text", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OutboundRecs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OutboundRecs_MatlWhse_MatlWhseId",
                        column: x => x.MatlWhseId,
                        principalSchema: "Erp",
                        principalTable: "MatlWhse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "OutboundDetls",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    OutboundRecId = table.Column<Guid>(type: "uuid", nullable: false),
                    IndexNo = table.Column<int>(type: "integer", nullable: false),
                    Bchno = table.Column<string>(type: "text", nullable: false),
                    TrdnFlag = table.Column<bool>(type: "boolean", nullable: false),
                    MatlInfoId = table.Column<Guid>(type: "uuid", nullable: false),
                    InboundPric = table.Column<decimal>(type: "numeric(18,6)", nullable: false),
                    Cnt = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
                    FinlTrnsPric = table.Column<decimal>(type: "numeric(18,6)", nullable: false),
                    FinlTrnsAmt = table.Column<decimal>(type: "numeric(18,6)", nullable: false),
                    Exp = table.Column<string>(type: "text", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OutboundDetls", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OutboundDetls_MatlInfo_MatlInfoId",
                        column: x => x.MatlInfoId,
                        principalSchema: "Erp",
                        principalTable: "MatlInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_OutboundDetls_OutboundRecs_OutboundRecId",
                        column: x => x.OutboundRecId,
                        principalTable: "OutboundRecs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_OutboundDetls_MatlInfoId",
                table: "OutboundDetls",
                column: "MatlInfoId");

            migrationBuilder.CreateIndex(
                name: "IX_OutboundDetls_OutboundRecId",
                table: "OutboundDetls",
                column: "OutboundRecId");

            migrationBuilder.CreateIndex(
                name: "IX_OutboundRecs_MatlWhseId",
                table: "OutboundRecs",
                column: "MatlWhseId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "OutboundDetls");

            migrationBuilder.DropTable(
                name: "OutboundRecs");
        }
    }
}
